package com.lk2.core.config
{
	import com.lk2.core.events.ConfigEvent;
	
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	
	public class RemoteConfigObj extends AbsConfigObj
	{
		
		public function RemoteConfigObj(configFileURL:String)
		{
			super(configFileURL);

			var configService:HTTPService = new HTTPService();
			configService.url = configFileURL;
			configService.resultFormat="e4x";
			configService.method = "post";
			configService.addEventListener(ResultEvent.RESULT, configObjReady);
			configService.addEventListener(FaultEvent.FAULT,configObjError);
			configService.send();
			
		}
		
		private function configObjReady(event:ResultEvent):void{
			this.configXML = event.result as XML;
			dispatchEvent(new ConfigEvent(ConfigEvent.CONFIG_LOADED));
		}

		
		private function configObjError(event:FaultEvent):void{
			trace("Errore:"+event.fault.message);
		}
		

	}
}